package com.tuo51.childcare.domain.carestore;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.tuo51.foudation.model.Domain;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.List;

@Data
@Entity
@Table(name = "m_storeitem_category")
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class StoreItemCategory extends Domain {

    @Column(columnDefinition = " varchar(45)  COMMENT '标题'")
    private String title;

    @Column(name = "channel", columnDefinition = " varchar(45)  COMMENT '渠道'")
    private String channel;

    @Column(columnDefinition = "varchar(512)  COMMENT '标签'")
    private String tags;


    @Column( name = "parent_id", columnDefinition = "varchar(32) default '' COMMENT '父分类id'")
    private String parentId;

    @ManyToOne
    @JoinColumn(name = "parent_id", insertable = false, updatable = false)
    @JsonIgnore
    private StoreItemCategory parent;

    @Column( name = "static_code", columnDefinition = "varchar(32)  COMMENT '静态编码'", unique = true)
    private String staticCode;

    @Column( name = "order_weight", columnDefinition = "int(11) default 0  COMMENT '排序权重'")
    private int orderWeight;

    @Column(columnDefinition = " bit DEFAULT 0 COMMENT '是否只有vip可见 0：否，1是' ")
    private Boolean vip = false;

    @Column(columnDefinition = " bit DEFAULT 0 COMMENT '隐藏' ")
    private Boolean hidden = false;

    @OneToMany(fetch = FetchType.EAGER, mappedBy = "parent")
    private List<StoreItemCategory> subCategories;
}
